//
//  SiftView.m
//  ZhuoxinAgriculture
//
//  Created by stone on 16/11/19.
//  Copyright © 2016年 stone. All rights reserved.
//

#import "SNProductionSiftView.h"

@implementation SNProductionSiftButton

-(void)setHighlighted:(BOOL)highlighted{
    
}

@end
//=************************ stone ***
@interface SNProductionSiftView()
@property (weak, nonatomic) IBOutlet SNProductionSiftButton *artelButton;
@property (weak, nonatomic) IBOutlet SNProductionSiftButton *farmButton;
@property (weak, nonatomic) IBOutlet SNProductionSiftButton *retailInvestorButton;
@property (strong, nonatomic) IBOutletCollection(SNProductionSiftButton) NSArray *buttons;

@end
@implementation SNProductionSiftView
- (IBAction)artelButtonClicked:(SNProductionSiftButton *)sender {
    
    sender.selected = !sender.selected;
    
    if (sender.selected) {
        sender.layer.borderColor = HexRGB(0x65B64E).CGColor;
        sender.layer.borderWidth = 1;
        [sender setTitleColor:HexRGB(0x65B64E) forState:UIControlStateNormal];
    }else{
        sender.layer.borderColor = [UIColor clearColor].CGColor;
        sender.layer.borderWidth = 0;
        [sender setTitleColor:HexRGB(0x000000) forState:UIControlStateNormal];
    }
    
}
- (IBAction)farmButtonClicked:(SNProductionSiftButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected) {
        sender.layer.borderColor = HexRGB(0x65B64E).CGColor;
        sender.layer.borderWidth = 1;
        [sender setTitleColor:HexRGB(0x65B64E) forState:UIControlStateNormal];
    }else{
        sender.layer.borderColor = [UIColor clearColor].CGColor;
        sender.layer.borderWidth = 0;
        [sender setTitleColor:HexRGB(0x000000) forState:UIControlStateNormal];
    }
    
}
- (IBAction)retailInvestorButtonClicked:(SNProductionSiftButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected) {
        sender.layer.borderColor = HexRGB(0x65B64E).CGColor;
        sender.layer.borderWidth = 1;
        [sender setTitleColor:HexRGB(0x65B64E) forState:UIControlStateNormal];
    }else{
        sender.layer.borderColor = [UIColor clearColor].CGColor;
        sender.layer.borderWidth = 0;
        [sender setTitleColor:HexRGB(0x000000) forState:UIControlStateNormal];
    }
}

+ (instancetype)view{
    
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
}
- (IBAction)downButtonClicked:(UIButton *)sender {
    
    !self.downButtonClickedBlock ?: self.downButtonClickedBlock(self.buttons);
    
    if (self.bgView) {
        
        [self.bgView removeFromSuperview];
    }
    [self removeFromSuperview];
}
-(void)setSelectedIndexs:(NSMutableArray<NSNumber *> *)selectedIndexs{
    _selectedIndexs = selectedIndexs;
    
    for(int i = 0; i < selectedIndexs.count; i++) {
        SNProductionSiftButton * siftButton = self.buttons[selectedIndexs[i].integerValue];
        siftButton.selected = YES;
        
        if (siftButton.selected) {
            siftButton.layer.borderColor = HexRGB(0x65B64E).CGColor;
            siftButton.layer.borderWidth = 1;
            [siftButton setTitleColor:HexRGB(0x65B64E) forState:UIControlStateNormal];
        }else{
            siftButton.layer.borderColor = [UIColor clearColor].CGColor;
            siftButton.layer.borderWidth = 0;
            [siftButton setTitleColor:HexRGB(0x000000) forState:UIControlStateNormal];
        }
    }
}

@end
